#!/bin/bash
# Installation script for GSI Wiki Generator

set -e

echo "🚀 Installing GSI Wiki Generator..."

# Check Python version
python_version=$(python3 --version 2>&1 | cut -d' ' -f2)
echo "📋 Python version: $python_version"

# Check if codebase-rag is available
if ! command -v codebase-rag &> /dev/null; then
    echo "⚠️  Warning: codebase-rag command not found in PATH"
    echo "   Please install codebase-rag before using this tool"
    echo "   Visit: https://github.com/your-repo/codebase-rag"
fi

# Check if claude CLI is available
if ! command -v claude &> /dev/null; then
    echo "⚠️  Warning: claude command not found in PATH"
    echo "   Please install Claude CLI before using this tool"
    echo "   Visit: https://claude.ai/cli"
fi

# Install the package
echo "📦 Installing GSI Wiki Generator package..."
pip install -e .

# Create default configuration if it doesn't exist
config_dir="$HOME/.config/gsi-wiki-generator"
mkdir -p "$config_dir"

if [ ! -f "$config_dir/config.json" ]; then
    echo "⚙️  Creating default configuration..."
    gsi-wiki-gen --create-config "$config_dir/config.json"
fi

echo "✅ Installation completed successfully!"
echo ""
echo "📋 Quick start:"
echo "   gsi-wiki-gen --help"
echo "   gsi-wiki-gen --input-dir /path/to/comGSI-wiki --output-dir ./output"
echo ""
echo "📁 Configuration file: $config_dir/config.json"